<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp" %>
<script>
    $(function () {
        $("#symptom").val(unescape($("#symptom").val()));
        $("#examApplyTable").treeTable();

    })
    function page(n,s){
        $("#pageNo").val(n);
        $("#pageSize").val(s);
        $("#examApplyForm").submit();
        return false;
    }
    function printPresc(examId,clinicId,patientId){
        printPdf('${ctx}/exam/examApply/printPresc', 'examId='+examId +'&clinicId='+clinicId+'&patientId='+patientId);
    }


    function selectResult(examId,clinicId,patientId){
        $.ajax({
            type: 'get',
            url: '${ctx}/exam/examApply/printPresc' ,
            dataType: dataType,
            success: function(data){

            }

        })
    }
</script>
 <div class="wrapper no-p" style="background-color: white">
    <div class="table-responsive no-border">
        <%--检查申请table--%>
        <div class="datatable-top">
            <div class="pull-left">
                <form:form hidden="hidden" id="examApplyForm" modelAttribute="examApply"
                           onsubmit="return loadDivForm('rightDiv','examApplyForm','${ctx}/exam/examApply/queryByCondition');"
                           method="post" class="form-inline">
                    <form:hidden path="patientId" id="patientId"/>
                    <form:hidden path="clinicId" id="clinicId"/>

                    <input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
                    <input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
                    <%--检查项目 ：--%>
                    <%--<form:input path="itemName" htmlEscape="false" maxlength="50"--%>
                                                     <%--class="form-control"/> &nbsp;--%>
                    <%--<input id="btnSubmit" class="btn btn-primary" type="submit" value="查询"/>--%>
                </form:form>
            </div>
        </div>
        <table id="examApplyTable" class="table table-bordered mg-t datatable">
            <thead>
            <tr>
                <th>申请时间</th>
                <th>申请单号</th>
                <th>执行科室</th>
                <th>收费状态</th>
                <th>确认状态</th>
                <th>操作</th>
            </tr>
            </thead>
            <tbody>
            <c:forEach items="${page.list}" var="examApply" varStatus="ex">
            <tr id="${examApply.id}">
                <td><fmt:formatDate value="${examApply.createDate}" pattern="yyyy-MM-dd HH:mm:ss"/></td>
                <td>${examApply.applyOn}</td>
                <td>${examApply.implementDeptEt.deptName}</td>
                <td>${fns:getDictLabels(examApply.chargeFlag,'NO_CHARGE','')}</td>
                <td>${fns:getDictLabels(examApply.confirmFlag,'CONFIRM_DICT','')}</td>
                <td>
                    <c:if test="${examApply.chargeFlag eq 1 && examApply.confirmFlag eq 0}">
                            <a href="#" class="applyBt btn btn-warning btn-xs"
                               onclick="confirmExtend('确认要申请退费吗？',function(){delLoad('rightDiv','${ctx}/finance/refundChargesApply/save?ordersId=${examApply.ordersId}&applyType=0','${ctx}/exam/examApply/queryByCondition?clinicId=${examApply.clinicId}&patientId=${examApply.patientId}&inoroutFlag=0')})">退费</a>
                        <a href="#"
                           class="btn btn-warning btn-xs"
                           onclick="printPresc('${examApply.id}','${examApply.clinicId}','${examApply.patientId}')">打印</a>
                    </c:if>
                    <c:if test="${examApply.chargeFlag eq 3}">
                        退费中
                    </c:if>
                    <c:if test="${examApply.chargeFlag=='0'}">
                        <a href="#" class="applyBt btn btn-danger btn-xs"
                           onclick="confirmExtend('确认要删除该申请吗？',function(){delLoad('rightDiv','${ctx}/exam/examApply/delete?id=${examApply.id}','${ctx}/exam/examApply/queryByCondition?clinicId=${examApply.clinicId}&patientId=${examApply.patientId}&inoroutFlag=0')})">删除</a>
                        <a href="#"
                           class="btn btn-warning btn-xs"
                           onclick="printPresc('${examApply.id}','${examApply.clinicId}','${examApply.patientId}')">打印</a>
                    </c:if>
                    <c:if test="${examApply.chargeFlag eq 1 && examApply.confirmFlag eq 1}">
                        <a href="https:// api.yizhen.cn /amol-back/clinicalIMages/autoLogin?hospitalId=100485&loginName=${loginName}&password=1&accessionNo=${examApply.applyOn}"
                           class="btn btn-warning btn-xs"  target="_Blank">查看结果</a>
                    </c:if>
                </td>
            </tr>
            <c:if test="${examApply.examItemList.size()>0}">
            <tr id="${ex.count}" pid="${examApply.id}">
                <td colspan="6" >
                    <table class="table table-bordered mg-t">
                        <tr>
                            <th>检查项目</th>
                            <th>价格</th>
                        </tr>
                        <c:forEach items="${examApply.examItemList}" var="examItems" varStatus="ss">
                            <tr>
                                <td>${examItems.itemName}</td>
                                <td>${examItems.costs}</td>
                            </tr>
                        </c:forEach>
                    </table>
                </td>

            </tr>
            </c:if>
            </c:forEach>
            </tbody>
        </table>
        <div class="pagination">${page}</div>
    </div>
</div>

